<template>
	<div class="hotpic">
		<div class="dd">
			<div class="d1">
				<div class="d2">
					<p class="p1">书籍管理</p>
					—
					<p>书籍类型</p>
				</div>
				<div class="im">
					<el-button icon="el-icon-refresh-right"></el-button>
				</div>
			</div>
			<div class="hr"></div>
			<div class="d3" @click="add()">
				<el-button type="primary" size="mini">添加热点图片</el-button>
			</div>
			<el-table :data="hotlist" class="d4" border>
				<el-table-column prop="id" label="描述"></el-table-column>
				<el-table-column prop="memo" label="类型"></el-table-column>
				<el-table-column prop="hot" label="优先级"></el-table-column>
				<!-- <el-table-column prop="value" label="状态">
				<template slot-scope="scope">
					<el-switch v-model="scope.row.value" active-color="#13ce66" inactive-color="#ff4949"
						@change="Status()" true-label="启用" false-label="禁止"></el-switch>
				</template>
			</el-table-column> -->
				<el-table-column prop="picture" label="图片">
					<template slot-scope="scope">
						<el-image :src="`http://127.0.0.1/api/public/showimg/${scope.row.picture}`"></el-image>
					</template>
				</el-table-column>
				<el-table-column label="管理">
					<template slot-scope="scope">
						<el-button type="primary" icon="el-icon-edit" @click="Edit(scope.row)">编辑</el-button>
						<el-button type="danger" class="d8" icon="el-icon-delete" @click="Delete()">删除
						</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
	</div>
</template>

<script>
	export default {
		name: 'HotPic',
		data() {
			return {
				hotlist: [],
			}
		},
		methods: {
			getHotBook() {
				const token = localStorage.getItem('token'); // 从本地存储获取 token  
				this.$axios.get("http://127.0.0.1/api/adm/hot/findAll", {
					headers: {
						'Authorization': `Bearer ${token}` // 将 token 添加到请求头中  
					}
				}).then((resp) => {
					resp.data.data.forEach((item) => {
						this.hotlist.push(item);
						console.log(this.hotlist);
					})

					console.log(this.hotlist)
				})
			},
			Edit(arr) {
				console.log(55555)
				this.$router.push({
					path: '/home/uphotpic',
					query: {
						arr
					}
				})
			},
			add() {
				this.$router.push({
					path: '/home/addhotpic',
					// query: {
					// 	arr
					// }
				})
			},
			Delete(){
				alert('删除接口未开发....');
			}
		},
		mounted() {
			this.getHotBook();
		},
	}
</script>

<style scoped>
	.hotpic {
		width: 85%;
	}

	.hotpic .hr {
		margin-top: 1%;
		border: 1px solid #f4f4f4;
	}

	.hotpic .dd {
		width: 95%;
		margin-left: 5%;
	}

	.hotpic .d1 {
		display: flex;
		justify-content: space-between;
		margin-top: 2%;
	}

	.d1 .p1 {
		color: #a7adb2;
	}

	.d1 .im .el-button {
		background-color: #2da99d;
		color: white;
		border-radius: 5px;
	}

	.d2 {
		width: 17%;
		display: flex;
		justify-content: space-between;
	}

	.d3 button {
		margin-top: 1%;
		width: 9%;
		height: 35px;
		background-color: #009688;
		color: white;
		border-radius: 5%;
		border: none;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
